//
//  SLGuideVC.swift
//  sulit-loan
//
//  Created by 王刚锋 on 2025/4/6.
//  Copyright © 2025 coolBoy. All rights reserved.
//

import UIKit

class SLGuideVC: SLBaseVC {

    override func viewDidLoad() {
        super.viewDidLoad()
        scrollView.addSubview(leftView)
        scrollView.addSubview(rightView)
        self.leftImage.isHidden = false
        self.leftSeg.isHidden = false
        self.skipBtn.isHidden = false
        self.nextBtn.isHidden = false
        self.rightImage.isHidden = false
        self.startBtn.isHidden = false
    }
    lazy var scrollView:UIScrollView = {
        let v = create_scrollView(supView: self.view) { make in
            make.left.right.top.bottom.equalTo(0)
        }
        v.contentSize = CGSizeMake(DevConfig.width*2, DevConfig.heigth)
        v.backgroundColor = .clear
        v.isScrollEnabled = false
        return v
    }()
    lazy var leftView:UIView = {
        let v = UIView(frame: CGRect(x: 0, y: 0, width: DevConfig.width, height: DevConfig.heigth))
        v.backgroundColor = .clear
        return v
    }()
    
    lazy var rightView:UIView = {
        let v = UIView(frame: CGRect(x: DevConfig.width, y: 0, width: DevConfig.width, height: DevConfig.heigth))
        v.backgroundColor = .clear
        return v
    }()
    lazy var leftImage:UIImageView = {
        let v = create_imageView(image: IMAGE("Group 1312316643"), mode: .scaleAspectFill, supView: leftView) { make in
            make.left.right.top.bottom.equalTo(0)
        }
        return v
    }()
    lazy var leftSeg:UIImageView = {
        let v = create_imageView(image: IMAGE("Step_1"), mode: .scaleAspectFill, supView: leftView) { make in
            make.width.equalTo(36)
            make.height.equalTo(10)
            make.centerX.equalToSuperview()
            make.bottom.equalTo(-203)
        }
        return v
    }()
    lazy var skipBtn:UIButton = {
        let v = create_button(title: "Skip", titleColor: rgba(hex: "#A3A3A3"), titleFont: SLFontConfig.regular16,bgColor: .white, image: nil, supView: self.leftView, closure: { make in
            make.width.equalTo(138)
            make.height.equalTo(44)
            make.bottom.equalTo(-50)
            make.right.equalTo(-DevConfig.width/2-7)
        }, selector: (target:self, action: #selector(buttonClick(btn: )), event: .touchUpInside))
        v.layer.cornerRadius = 22
        v.layer.borderWidth = 1
        v.layer.borderColor = rgba(hex: "#A3A3A3").cgColor
        return v
    }()
    lazy var nextBtn:UIButton = {
        let v = create_button(title: "Next", titleColor: .white, titleFont: SLFontConfig.regular16,bgColor: rgba(hex: "#1608EC"), image: nil, supView: self.leftView, closure: { make in
            make.width.equalTo(138)
            make.height.equalTo(44)
            make.bottom.equalTo(-50)
            make.left.equalTo(DevConfig.width/2+7)
        }, selector: (target:self, action: #selector(buttonClick(btn: )), event: .touchUpInside))
        v.layer.cornerRadius = 22
        return v
    }()
    lazy var rightImage:UIImageView = {
        let v = create_imageView(image: IMAGE("Group 1312316644"), mode: .scaleAspectFill, supView: rightView) { make in
            make.left.right.top.bottom.equalTo(0)
        }
        return v
    }()
    lazy var startBtn:UIButton = {
        let v = create_button(bgColor: .clear, image: IMAGE("icon_enter"), supView: self.rightView, closure: { make in
            make.width.equalTo(80)
            make.height.equalTo(80)
            make.bottom.equalTo(-50)
            make.centerX.equalToSuperview()
        }, selector: (target:self, action: #selector(buttonClick(btn: )), event: .touchUpInside))
        v.layer.cornerRadius = 22
        return v
    }()

    @objc func buttonClick(btn: UIButton){
        if btn == nextBtn{
            scrollView.setContentOffset(CGPoint(x: DevConfig.width, y: 0), animated: true)
        }else{
            if let appDelegate = UIApplication.shared.delegate as? AppDelegate {
                appDelegate.jumpMainVC()
            }
        }
        
    }
}
